import db from '@/utils/pouchdb'

export function saveList(type, list) {
  const putData = {
    _id: type,
    list: list,
    time: new Date().getTime()
  }
  return db.get(type)
    .then(doc => {
      putData['_rev'] = doc._rev
      return db.put(putData)
    })
    .catch(() => {
      return db.put(putData)
    })
}

export function getList(type) {
  return db.get(type)
}
